-
Notifications
You must be signed in to change notification settings - Fork 13.6k
oneshot
Channel
#143741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
oneshot
Channel
#143741
Conversation
Maybe want to ask the unresolved questions at the ACP thread? To make sure it's seen by those already involved. (I'll take a closer look later) |
Because But mpmc is multiple producer multiple consumer, so it doesn't matter how many threads For this one, they can both be unconditionally |
Thank you for the answer! Please let me know if I'm interpreting this right: If all methods where synchronization must occur consume |
This commit adds tests for the very basic new oneshot module. Most of the tests were taken/heavily inspired by tests from the `oneshot crate.
This commit removes the unnecessary `unsafe impl Send` for `Sender` and `Receiver` as they both `Send` that from the inner `mpmc`. Additionally, this adds an unconditional `impl Sync` for `Sender` and `Receiver`.
Tracking Issue: #143674
This PR adds an experimental
oneshot
module.Before talking about the API itself, I would prefer to get some of these questions below out of the way first. And as discussed in the ACP it would be
Unresolved Questions
Why exactly is it okay forSender
to beSync
? Or basically, how do we boil down the discussion in ImplementSync
formpsc::Sender
#111087 into a comment for theunsafe impl<T: Send> Sync for Sender<T> {}
?Why ismpsc::Receiver
!Sync
butmpmc::Receiver
isSync
? Shouldoneshot::Receiver
beSync
or not?is_ready
method as proposed in the tracking issue? If so, then the surface of this PR would likely need to increase to add apub(crate) fn is_disconnected
method tompmc
(might even be a good idea to add that to all 3 channel flavors).mpmc
, or should it be a wrapper around the internal crossbeam implementation?Sender
andReceiver
operations be methods or associated methods? Sosender.send(msg)
orSender::send(sender, msg)
? The method syntax is more consistent with the rest of the ecosystem (namelytokio
)